<!DOCTYPE html>
<html>
<head>
    <title>Nuclear Level Diagram</title>
</head>
<body>
<canvas id="physics_diagram" width="500" height="280"></canvas>
<script>
    const canvas = document.getElementById('physics_diagram');
    const ctx = canvas.getContext('2d');

    // --- Style and Font Settings ---
    ctx.strokeStyle = 'black';
    ctx.fillStyle = 'black';
    ctx.lineWidth = 2;
    // Use a font that mimics old typewriter or technical text
    const baseFont = '26px "Courier New", monospace';
    const supFont = '18px "Courier New", monospace';
    const captionFont = '22px "Times New Roman", serif';

    // --- Coordinate Definitions ---
    const box = { x: 40, y: 40, width: 420, height: 160 };
    const y_upper = box.y + 50;  // 90
    const y_lower = box.y + 110; // 150
    const x_dash_left_start = box.x + 50;
    const x_dash_left_end = box.x + 180;
    const x_dash_right_start = box.x + 240;
    const x_dash_right_end = box.x + 370;
    const x_E_col = (x_dash_left_start + x_dash_left_end) / 2;
    const x_J_col = (x_dash_right_start + x_dash_right_end) / 2;
    const x_arrow = (x_dash_left_end + x_dash_right_start) / 2;
    const caption_y = box.y + box.height + 45;

    // 1. Draw the outer box
    ctx.strokeRect(box.x, box.y, box.width, box.height);

    // 2. Draw dashed lines for energy levels
    ctx.setLineDash([10, 5]);
    // Upper level
    ctx.beginPath();
    ctx.moveTo(x_dash_left_start, y_upper);
    ctx.lineTo(x_dash_left_end, y_upper);
    ctx.moveTo(x_dash_right_start, y_upper);
    ctx.lineTo(x_dash_right_end, y_upper);
    ctx.stroke();
    // Lower level
    ctx.beginPath();
    ctx.moveTo(x_dash_left_start, y_lower);
    ctx.lineTo(x_dash_left_end, y_lower);
    ctx.moveTo(x_dash_right_start, y_lower);
    ctx.lineTo(x_dash_right_end, y_lower);
    ctx.stroke();
    ctx.setLineDash([]); // Reset to solid line

    // 3. Draw the transition arrow
    ctx.lineWidth = 1.8;
    ctx.beginPath();
    ctx.moveTo(x_arrow, y_upper + 2); // Start slightly below the line
    ctx.lineTo(x_arrow, y_lower);
    ctx.stroke();
    // Arrowhead
    ctx.beginPath();
    ctx.moveTo(x_arrow, y_lower);
    ctx.lineTo(x_arrow - 6, y_lower - 10);
    ctx.moveTo(x_arrow, y_lower);
    ctx.lineTo(x_arrow + 6, y_lower - 10);
    ctx.stroke();
    ctx.lineWidth = 2; // Reset line width

    // 4. Draw text labels
    ctx.textAlign = 'center';
    
    // E column
    ctx.font = baseFont;
    ctx.fillText('0.37 MeV', x_E_col, y_upper - 10);
    ctx.fillText('0 MeV', x_E_col, y_lower - 10);
    ctx.fillText('E', x_E_col, y_lower + 40);

    // J^P column (manual placement for superscripts)
    // Upper level: 5/2⁻
    ctx.font = baseFont;
    ctx.fillText('5/2', x_J_col, y_upper - 5);
    ctx.font = supFont;
    ctx.fillText('−', x_J_col + 28, y_upper - 15);

    // Lower level: 7/2⁻
    ctx.font = baseFont;
    ctx.fillText('7/2', x_J_col, y_lower - 5);
    ctx.font = supFont;
    ctx.fillText('−', x_J_col + 28, y_lower - 15);

    // Column Label: J^P
    ctx.font = baseFont;
    ctx.fillText('J', x_J_col, y_lower + 40);
    ctx.font = supFont;
    ctx.fillText('P', x_J_col + 10, y_lower + 30);

    // 5. Draw the caption
    ctx.font = captionFont;
    ctx.textAlign = 'center';
    ctx.fillText('Fig. 2.14', canvas.width / 2, caption_y);

</script>
</body>
</html>